package src.main.StructuralPatterns.Bridge;

// 具体实现：电视机
public class TV implements Device{
    private boolean isOn = false;
    private int channel = 1;
    private int volume = 100;

    @Override
    public void powerOn() {
        isOn = true;
        System.out.println("TV is on");
    }

    @Override
    public void powerOff() {
        isOn = false;
        System.out.println("TV is off");
    }

    @Override
    public void setChannel(int channel) {
        if (isOn) this.channel = channel;
    }

    @Override
    public void printStatus() {
        System.out.println("Channel: " + channel);
        System.out.println("On: " + isOn);
        System.out.println("Volume: " + volume);
    }

    @Override
    public boolean isOn() {
        System.out.println("isOn: " + isOn);
        return this.isOn;
    }

    @Override
    public int getChannel() {
        return this.channel;
    }

    @Override
    public void setVolume(int volume) {
        if (isOn) {
            this.volume = Math.min(100, Math.max(0, volume));
            System.out.println("TV volume set to " + volume);
        }
    }

    @Override
    public int getVolume() {
        return this.volume;
    }
}
